﻿<shared:PageBase x:Class="Bymed.SpineScan.WPF.TestSummaryPage"
      xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
      xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
      xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
      xmlns:d="http://schemas.microsoft.com/expression/blend/2008"                 
      xmlns:shared="clr-namespace:Bymed.SpineScan.WPF.Shared"
      xmlns:interactivity="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity" 
      xmlns:userControl="clr-namespace:Bymed.SpineScan.WPF.CustomizedUserControl"
      x:Name="CurrentPage" 
      mc:Ignorable="d" 
      d:DesignHeight="800" d:DesignWidth="1200"
	  Title="TestSummaryReportPage" Style="{StaticResource DefaultPageStyle}"
      DataContext="{Binding TestSummary, Source={StaticResource Locator}}">
    <Page.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <ResourceDictionary Source="/Skins/Storyboard/PageStoryborad.xaml" />
            </ResourceDictionary.MergedDictionaries>
        </ResourceDictionary>
    </Page.Resources>
    <Grid Height="660" Width="1200">
        <Grid.RowDefinitions>
            <!-- Patient Info & Selected Test Items -->
            <RowDefinition />
            <!-- Navigation Buttons -->
            <RowDefinition Height="Auto" />
        </Grid.RowDefinitions>
        <Grid HorizontalAlignment="Center">
            <Grid.Background>
                <ImageBrush ImageSource="/Skins/Resource/Image/GrayRightAboveTabBackground.png" />
            </Grid.Background>
            <Grid.RowDefinitions>
                <!-- Page Title -->
                <RowDefinition Height="38" />
                <!-- Main Content -->
                <RowDefinition />
            </Grid.RowDefinitions>
            <TextBlock Margin="0,0,40,-2" Text="测试结果" Foreground="#153364" FontSize="26" VerticalAlignment="Bottom" HorizontalAlignment="Right" />
            <Grid Grid.Row="1" Margin="0,-10,0,0">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="260" />
                    <ColumnDefinition />
                </Grid.ColumnDefinitions>
                <userControl:PatientBasicInfoDisplayUserControl DataContext="{Binding PatientBasicInfoDisplayViewModel}" 
                   Margin="0,27,0,0" HorizontalAlignment="Right" Width="229" Height="483" VerticalAlignment="Top" />
                <Grid Grid.Column="1" Margin="0,0,0,12">
                    <Grid.RowDefinitions>
                        <!-- Tested Items -->
                        <RowDefinition />
                        <!-- Select All CheckBox -->
                        <!-- Remark List -->
                        <RowDefinition Height="Auto" />
                        <!-- Attached Diagnostic Message -->
                        <RowDefinition Height="Auto" />
                    </Grid.RowDefinitions>
                    <ScrollViewer Margin="30,30,10,0" HorizontalScrollBarVisibility="Disabled" VerticalScrollBarVisibility="Auto">
                        <ItemsControl ItemsSource="{Binding TestItemList}">
                            <ItemsControl.Template>
                                <ControlTemplate>
                                    <WrapPanel IsItemsHost="true" />
                                </ControlTemplate>
                            </ItemsControl.Template>
                            <ItemsControl.ItemTemplate>
                                <DataTemplate>
                                    <CheckBox Tag="{Binding}" Style="{StaticResource TestItemWithResultCheckBox}" />
                                </DataTemplate>
                            </ItemsControl.ItemTemplate>
                        </ItemsControl>
                    </ScrollViewer>
                    <Grid Grid.Row="1">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition />
                            <ColumnDefinition Width="125" />
                        </Grid.ColumnDefinitions>
                        <CheckBox Grid.Column="1" VerticalAlignment="Top" IsChecked="{Binding SelectAll}" Content="全选" 
                          Padding="5,0,0,0" FontSize="20" Style="{StaticResource GreenCheckBoxStyle}" />
                        <StackPanel Margin="20,0,0,0" VerticalAlignment="Bottom">
                            <TextBlock Text="备注" Margin="10,0,0,-8" FontSize="20" Visibility="Collapsed" />
                            <Grid Height="120">
                                <Grid.ColumnDefinitions>
                                    <ColumnDefinition Width="360" />
                                    <ColumnDefinition Width="Auto" />
                                    <ColumnDefinition Width="360" />
                                </Grid.ColumnDefinitions>
                                <Border Padding="15">
                                    <Border.Background>
                                        <ImageBrush ImageSource="/Skins/Resource/Image/GrayBackground.png" />
                                    </Border.Background>
                                    <ListBox x:Name="PredefinedDiagnosticMessageListBox" BorderThickness="0" 
                                Background="Transparent" ItemsSource="{Binding PredefinedDiagnosticMessageList}">
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding MessageContent}" />
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                        <interactivity:Interaction.Triggers>
                                            <interactivity:EventTrigger EventName="MouseDoubleClick">
                                                <interactivity:InvokeCommandAction Command="{Binding AddDiagnosticMessageCommand}" 
                                                           CommandParameter="{Binding SelectedItem, ElementName=PredefinedDiagnosticMessageListBox}" />
                                            </interactivity:EventTrigger>
                                        </interactivity:Interaction.Triggers>
                                    </ListBox>
                                </Border>
                                <StackPanel Grid.Column="1" Width="40" VerticalAlignment="Center" HorizontalAlignment="Center">
                                    <Button Tag="/Skins/Resource/Image/AddItem.png" HorizontalAlignment="Center" Width="35" 
                            Style="{StaticResource OpacityImageButton}" Command="{Binding AddDiagnosticMessageCommand}" 
                            CommandParameter="{Binding SelectedItem, ElementName=PredefinedDiagnosticMessageListBox}" />
                                    <Button Tag="/Skins/Resource/Image/RemoveItem.png" HorizontalAlignment="Center" Width="35" 
                            Style="{StaticResource OpacityImageButton}" Command="{Binding RemoveDiagnosticMessageCommand}" 
                            CommandParameter="{Binding SelectedItem, ElementName=SelectedDiagnosticMessageListBox}" />
                                </StackPanel>
                                <Border Grid.Column="2" Padding="15">
                                    <Border.Background>
                                        <ImageBrush ImageSource="/Skins/Resource/Image/GrayBackground.png" />
                                    </Border.Background>
                                    <ListBox x:Name="SelectedDiagnosticMessageListBox" Background="Transparent"
                             BorderThickness="0" ItemsSource="{Binding SelectedDiagnosticMessageList}">
                                        <ListBox.ItemTemplate>
                                            <DataTemplate>
                                                <TextBlock Text="{Binding MessageContent}" />
                                            </DataTemplate>
                                        </ListBox.ItemTemplate>
                                        <interactivity:Interaction.Triggers>
                                            <interactivity:EventTrigger EventName="MouseDoubleClick">
                                                <interactivity:InvokeCommandAction Command="{Binding RemoveDiagnosticMessageCommand}" 
                                                           CommandParameter="{Binding SelectedItem, ElementName=SelectedDiagnosticMessageListBox}" />
                                            </interactivity:EventTrigger>
                                        </interactivity:Interaction.Triggers>
                                    </ListBox>
                                </Border>
                            </Grid>
                        </StackPanel>
                    </Grid>
                    <StackPanel Grid.Row="2" Orientation="Horizontal">
                        <TextBox x:Name="TxtAttachedDiagnosticMessage" MaxLength="50" Margin="35,0,0,0" Height="45" Width="675" 
                             Text="{Binding AttachedDiagnosticMessage, Mode=OneWayToSource}" Style="{StaticResource InfoTextBox}" />
                        <TextBlock Margin="8,0,0,0" FontSize="24" Style="{StaticResource TestReportTitleTextBlock}">
                            <TextBlock.Text>
                                <MultiBinding StringFormat="{}{0}/{1}" UpdateSourceTrigger="PropertyChanged">
                                    <Binding ElementName="TxtAttachedDiagnosticMessage" Path="Text.Length" />
                                    <Binding ElementName="TxtAttachedDiagnosticMessage" Path="MaxLength" />
                                </MultiBinding>
                            </TextBlock.Text>
                        </TextBlock>
                    </StackPanel>
                </Grid>
            </Grid>
        </Grid>
        <StackPanel Grid.Row="1" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Bottom">
            <Button Content="上一步" Margin="0,0,120,0" Tag="/Skins/Resource/Image/Back.png" Style="{StaticResource NavigationButton}" Click="ButtonBack_Click" />
            <Button Content="打印" Margin="0,0,120,0" Tag="/Skins/Resource/Image/Print.png" Style="{StaticResource NavigationButton}" Command="{Binding ShowTestSummaryReportCommand}" />
            <Button Content="取消" Margin="0,0,120,0" Tag="/Skins/Resource/Image/Cancel.png" Style="{StaticResource NavigationButton}" Click="ButtonCancel_Click" />
            <Button Content="完成" Tag="/Skins/Resource/Image/Next.png" Style="{StaticResource NavigationButton}" Command="{Binding FinishCommand}" />
        </StackPanel>
    </Grid>
</shared:PageBase>
